package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.fabu.FabuInfoBean;
import com.lwj.liwanjia.impl.FabuInforView;
import com.lwj.liwanjia.model.FabuInfoModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2018/1/16.
 */

public class FabuInfoPresenter {
    private FabuInforView fabuInforView;
    private FabuInfoModel fabuInfoModel;

    public FabuInfoPresenter(FabuInforView fabuInforView) {
        this.fabuInforView = fabuInforView;
        this.fabuInfoModel = new FabuInfoModel();
    }

    public void getFabuData(String token, String commodityBatch) {
        fabuInfoModel.getFabuData(token, commodityBatch, new Subscriber<FabuInfoBean>() {
            @Override
            public void onCompleted() {
                fabuInforView.hideProgress();
            }

            @Override
            public void onError(Throwable e) {
                fabuInforView.showError((Exception) e);
                fabuInforView.hideProgress();
            }

            @Override
            public void onNext(FabuInfoBean fabuInfoBean) {
                fabuInforView.getFabuData(fabuInfoBean);
            }

            @Override
            public void onStart() {
                super.onStart();
                fabuInforView.showProgress();
            }
        });
    }
}
